# -*- coding: utf-8 -*-
import datetime

def round_to_minutes(dt):
    return datetime.datetime(*dt.timetuple()[:5])

def xdaterange(date_from, date_to, step=datetime.timedelta(1), reversed=False):
    if reversed:
        date = date_to
        while date > date_from:
            yield date
            date -= step
    else:
        date = date_from
        while date < date_to:
            yield date
            date += step
